package org.wutopia.labcloud.service.api.service.seata;

import org.apache.seata.rm.tcc.api.BusinessActionContext;
import org.apache.seata.rm.tcc.api.BusinessActionContextParameter;
import org.apache.seata.rm.tcc.api.TwoPhaseBusinessAction;

public interface TccProductService {

    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "productStockpileAccomplish",
            rollbackMethod = "productStockpileFrozenThawed",
            useTCCFence = true)
    boolean productStockpileFrozen(BusinessActionContext actionContext,
                                @BusinessActionContextParameter(paramName = "productId")Long productId,
                                @BusinessActionContextParameter(paramName = "frozen")Integer frozen) throws Exception;

    boolean productStockpileAccomplish(BusinessActionContext actionContext) throws Exception;

    boolean productStockpileFrozenThawed(BusinessActionContext actionContext) throws Exception;

    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "stockpileReturnAccomplish",
            rollbackMethod = "stockpileFrozenCancel",
            useTCCFence = true)
    boolean stockpileFrozenReturn(BusinessActionContext actionContext,
                                   @BusinessActionContextParameter(paramName = "productId")Long productId,
                                   @BusinessActionContextParameter(paramName = "frozen")Integer frozen);

    boolean stockpileReturnAccomplish(BusinessActionContext actionContext);

    boolean stockpileFrozenCancel(BusinessActionContext actionContext);

    @TwoPhaseBusinessAction(name = "TccProductService",
            commitMethod = "stockpileReleaseAccomplish",
            rollbackMethod = "stockpileReleaseCancel",
            useTCCFence = true)
    boolean stockpileFrozenRelease(BusinessActionContext actionContext,
                                  @BusinessActionContextParameter(paramName = "productId")Long productId,
                                  @BusinessActionContextParameter(paramName = "frozen")Integer frozen) throws Exception;

    boolean stockpileReleaseAccomplish(BusinessActionContext actionContext);

    boolean stockpileReleaseCancel(BusinessActionContext actionContext) throws Exception;



}
